package com.myspring.web.form;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * PropertyEditorRegistrySupport 类注册各种类型转换器，也可以自己继承PropertyEditorSupport实现自己的转换器
 * 
 * http://www.baeldung.com/jackson-serialize-enums枚举转换的几种实现方式
 */
public class MixForm {
	private String username;
	private String password;
	private List<String> group;
	private String single1;
	private String single2;
	private List<Integer> markets;
	private Integer sex;
	private List<Student> students;
	private BigDecimal fee;
	private Map<String, Object> map;
	private Map<String, List<Student>> mapList;
	private String hiddenVal;
	private ChooseType chooseType = ChooseType.YES;
	// @DateTimeFormat(pattern = "yyyy-MM-dd")
	@DateTimeFormat(iso = ISO.DATE)
	private Date createTime;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<String> getGroup() {
		return group;
	}

	public void setGroup(List<String> group) {
		this.group = group;
	}

	public String getSingle1() {
		return single1;
	}

	public void setSingle1(String single1) {
		this.single1 = single1;
	}

	public String getSingle2() {
		return single2;
	}

	public void setSingle2(String single2) {
		this.single2 = single2;
	}

	public List<Integer> getMarkets() {
		return markets;
	}

	public void setMarkets(List<Integer> markets) {
		this.markets = markets;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

	public BigDecimal getFee() {
		return fee;
	}

	public void setFee(BigDecimal fee) {
		this.fee = fee;
	}

	public Map<String, Object> getMap() {
		return map;
	}

	public void setMap(Map<String, Object> map) {
		this.map = map;
	}

	public String getHiddenVal() {
		return hiddenVal;
	}

	public void setHiddenVal(String hiddenVal) {
		this.hiddenVal = hiddenVal;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public ChooseType getChooseType() {
		return chooseType;
	}

	public void setChooseType(ChooseType chooseType) {
		this.chooseType = chooseType;
	}

	public Map<String, List<Student>> getMapList() {
		return mapList;
	}

	public void setMapList(Map<String, List<Student>> mapList) {
		this.mapList = mapList;
	}



	enum ChooseType {
		YES(1, "是"), NO(0, "否");

		private int index;
		private String name;

		ChooseType(int index, String name) {
			this.index = index;
			this.name = name;
		}

		public int getIndex() {
			return index;
		}

		public void setIndex(int index) {
			this.index = index;
		}

		@JsonValue
		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

	}
}
